const path = require('path');
const IS_PROD = ['production', 'test'].includes(process.env.NODE_ENV)
const PROXY_TARGET = process.env.PROXY_TARGET || 'CS'
const PROXY_URL = {
	// QJ: 'http://192.168.13.143:8889',
	CS: 'http://192.168.7.237:8889',
	SHW: 'http://192.168.13.206:20030',
	FJX: 'http://192.168.13.206:20030',
	WM: 'http://192.168.13.206:20030'
}
console.log('proxy:', PROXY_TARGET)
console.log('PROXY_URL:', PROXY_URL[PROXY_TARGET])
function resolve (dir) {
	return path.join(__dirname, dir)
}
module.exports = {
	publicPath: '',

	outputDir: 'dist',

	assetsDir: './src/assets',

	lintOnSave: 'error',

	indexPath: './index.html',

	css: {
		extract: IS_PROD,

		sourceMap: false,

		loaderOptions: {},

		modules: false,

		loaderOptions: {
			less: {
			}
		}
	},
	chainWebpack: (config)=>{
		config.resolve.alias
			.set('$assets', resolve('src/assets'))
			.set('images', resolve('src/assets/images'))
			.set('$json', resolve('src/json'))
	},
	devServer: {
		host: '0.0.0.0',
		port: 8877,
		https: false,
		hotOnly: true,
		proxy: {
			'/archive': {
				target: PROXY_URL[PROXY_TARGET],
				changeOrigin: true
			},
			'/technology': {
				target: PROXY_URL[PROXY_TARGET],
				changeOrigin: true
			},
			'/schedule': {
				target: PROXY_URL[PROXY_TARGET],
				changeOrigin: true
			}
		},
		before: app => {},
		disableHostCheck: true
	}
}
